package com.xingkeduo.dto;

import com.xingkeduo.pojo.table.Comments;
import com.xingkeduo.pojo.table.Order;
import com.xingkeduo.utils.DateTimeUtils;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.time.Duration;
import java.time.temporal.TemporalUnit;

import static com.xingkeduo.utils.DateTimeUtils.HH_mm;
import static com.xingkeduo.utils.DateTimeUtils.yyyy_MM_dd_HH_mm_ss;

/**
 * @author chi  2019-02-15 17:25
 **/
@Data
public class CommentsResponseDto extends Comments {

    private int startNum;

    /**
     * 星级对应的评价
     */
    private String startName;

    /**
     * 评价标签
     */
    private String[] judgementLabels;

    private String createdTimeShow;


    private String statusName;

    private String serviceTimeLast;
    private String serviceTimeShow;

    private String[] pictures;

    public void covert(){
        this.startNum = this.getCommentStar().getKey();
        this.startName = this.getCommentStar().getValue();
        this.judgementLabels = this.getJudgementLabel().split(",");
        this.createdTimeShow = this.getCreatedTime().format(yyyy_MM_dd_HH_mm_ss);
        this.statusName = this.getIsEffective() ? "有效" : "无效";

        try {
            String s1 = this.getServeStartTime().toLocalDate() + " " + this.getServeStartTime().toLocalTime().format(HH_mm) + "~" + this.getServeEndTime().toLocalTime().format(HH_mm);
            this.serviceTimeShow = s1;
        } catch (Exception e) {
        }

        try {
            this.serviceTimeLast = DateTimeUtils.minuteAndSecond(this.getServeStartTime(), this.getServeEndTime());
        } catch (Exception e) {
        }

        String picIds = this.getPicIds();
        if(StringUtils.isNotBlank(picIds)){
            String[] split = picIds.split(",");
            this.pictures = split;
        }
    }
}
